<template>
  <div class="col p10 card">
    <label class="title">喷嘴控制</label>
    <div class="row_center mt">
      <label>离开零点距离:</label>
      <el-input v-model="ctx.distance" style="width: 80px;"/>
    </div>
    <div class="row_center mt">
      <el-button @click="onClickCtrl" type="primary">控制</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue';
import { dialog } from '../../service/ui';
import { nozzle_ctrl } from '../../service/heat_cmd';


interface Ctx {
  distance: string,
}

const ctx = reactive<Ctx>({
  distance: '0'
});

async function onClickCtrl() {
  try {
    const val = parseInt(ctx.distance);
    await nozzle_ctrl(val);
    dialog.succ('成功');
  } catch (msg) {
    dialog.err(msg);
  }
}

</script>
